﻿#include "Enemy.h"
#include "cocos2d.h"
#include "cocos-ext.h"
#include "Config.h"

using namespace cocos2d;
using namespace cocos2d::extension;

Enemy::Enemy()
{
	initValueForAttribute( FBANANA, ccp(0,0), FISLEFT); 
}
Enemy::Enemy(int type)
{
	initValueForAttribute( type, ccp(0,0), FISLEFT);
}
Enemy::Enemy(int type, CCPoint p)
{
	initValueForAttribute( type, p, FISLEFT);
}
Enemy::Enemy(int type, CCPoint p, int left)
{
	initValueForAttribute( type, p, left);
}

void Enemy::initValueForAttribute(int type, CCPoint p, int left)
{
	initWithFile(fSelectObjectImage());
	mType = type;
	if(left == 1)
	{
		p.x -= getContentSize().width/2;
	}
	else
	{
		p.x += getContentSize().width/2;
	}
	setPosition(p);
	mIsLeft = left;
	mNewStatus = FSHOW;
	mCurrentStatus = FSHOW;
}

char* Enemy::fSelectObjectImage()
{
	switch(mType)
	{
	case ESNAKE:
		return kImageEnemySnake;
	case EWORM:
		return kImageEnemyWorm;
	case ECENTIBEDE:
		return kImageEnemyCentibede;
	default: 
		return kImageEnemySnake;
	}
}

void Enemy::fPreLoadMusic()
{
	CCLog("PreLoad music !!!!");
	//CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect(kSoundBroken);
}

void Enemy::fEffect()
{
	switch(mCurrentStatus)
	{
			//action
			//play sound effect here

		case ESHOW: //hien
			// CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(kSoundBroken);
			break;

		case EATTACK: //an
			// CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(kSoundBroken);
			break;

		case ECOLLISION: //va cham
			// CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(kSoundBroken);
			break;

		default: 
			break;
	}
}
